import request from '@/utils/request'

export default {
    addOnePurchase(Message) {
        console.log(Message);
        const req = request({
            method: 'post',
            url: '/dgut/addOnePurchaseMessage',
            params: {
                psid: Message.psid,
                peid: Message.peid,
                pcounts: Message.pcounts
            }
        })
        return req;
    },
    search(searchMap) {
        if (searchMap.pid != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getPurchaseMessageByPid',
                params: {
                    pid:searchMap.pid
                }
            })
            return req;
        } else if (searchMap.psid != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getPurchaseMessageByPsid',
                params: {
                    psid:searchMap.psid
                }
            })
            return req;
        } else if (searchMap.pename != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getPurchaseMessageByEname',
                params: {
                    ename:searchMap.pename
                }
            })
            return req;
        } else if (searchMap.psmaterial != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getPurchaseMessageByMaterial',
                params: {
                    material:searchMap.psmaterial
                }
            })
            return req;
        } else {
            const req = request({
                method: 'get',
                url: '/dgut/getAllPurchaseMessage'
            })
            return req;
        }
    }
}